var gulp = require('gulp'),
    connect = require('gulp-connect')
    watch = require('gulp-watch');

gulp.task('server', function () {
	connect.server({
		port: 8081,
		host: 'localhost',
		livereload: true
	});
});

gulp.task('livereload', function() {
	watch('publish/*.*')
		.pipe(connect.reload());
});


gulp.task('dist', function () {
    gulp.src(['src/*.html'])
        .pipe(gulp.dest('publish'));
});

gulp.task('watch', function () {
	var watcher = gulp.watch('src/*.*', ['dist']);
	watcher.on('change', function (event) {
		console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
	});
});

gulp.task('default', ['server', 'livereload', 'dist', 'watch']);
